﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="J_MyOrder.ascx.cs" Inherits="Pub_Module_J_MyOrder" %>
<%@ Register Src="../../Pub/Module/Calendar.ascx" TagName="Calendar" TagPrefix="uc1" %>
<link href="<%= ResolveClientUrl("~/")%>Pub/Css/JQ/jquery-ui-1.8.13.custom.css" rel="stylesheet"
    type="text/css" />

<script type="text/javascript" src="<%= ResolveClientUrl("~/")%>Pub/Js/JQ/jquery-ui-1.8.13.custom.min.js"></script>

<script type="text/javascript">
      var Url='<%= ResolveClientUrl("~/")%>';
    
    
			$(function(){
			
				// Dialog			
				$('#dialog').dialog({
					autoOpen: false,
					width: 600
					/*,buttons: {
						"Ok": function() { 
							$(this).dialog("close"); 
						}, 
						"Cancel": function() { 
							$(this).dialog("close");
						} 
					} */
				});
				
				// Dialog Link
				$('.dialog_link').click(function(){				
				    $("#<%= divLoading.ClientID%>").show();
				    $('#ifOderDetail').text("");				
					$('#dialog').dialog('open');						
					$("#ifOderDetail").load(Url+"Member/MyOrder/OrderDetail.aspx?OrderID="+$(this).attr("OrderID")+"&State="+$(this).attr("Status"), function(response, status, xhr) {
                          if (status == "error") {
                                var msg = "Sorry but there was an error. Contact Admin ";
                                alert(msg);
                                $('#dialog').dialog("close");  
                          }
                         else
                          {
                              $("#<%= divLoading.ClientID%>").hide();
                          }   
                    });

					
					return false;
				});
				
				//hover states on the static widgets
				$('.dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
			});
			
			
</script>

<style type="text/css">
			/*demo page css*/
		
			.demoHeaders { margin-top: 2em; }
			.dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}			
			.dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
			ul#icons {margin: 0; padding: 0;}
			ul#icons li {margin: 2px; position: relative; padding: 4px 0; cursor: pointer; float: left;  list-style: none;}
			ul#icons span.ui-icon {float: left; margin: 0 4px;}
			.TextOrderID:hover{color:Orange}
		</style>
<div style="background-color: White; padding: 5px; text-align: center" class="div_skin-tango">
    <div class="coverlblTitleProduct">
        <asp:Label ID="lblTitleProduct" runat="server" Text="QUẢN LÝ ĐƠN ĐẶT HÀNG" CssClass="lblTitleProduct"></asp:Label></div>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" class="tbl_News">
        <tr>
            <td class="td_TitileNews_590">
            </td>
        </tr>
        <tr>
            <td class="td_Content_590">
                <table width="100%" style="padding-left: 5px; padding-right: 5px;" cellpadding="0"
                    cellspacing="0">
                    <tr>
                        <td align="center" height="40px" valign="middle">
                            <table cellpadding="0" cellspacing="0" style="width: 100%; background-color: White">
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td class="td_MyOrder" style="white-space: nowrap">
                                        <asp:Label ID="Label2" runat="server" Text="Mã đơn hàng:" Style="font-weight: bold"></asp:Label>
                                    </td>
                                    <td style="width: 20%" align="left">
                                        <asp:TextBox ID="txtOrderID" runat="server" CssClass="txt_Common"></asp:TextBox>
                                    </td>
                                    <td class="td_MyOrder" style="width: 20%; white-space: nowrap">
                                        <asp:Label ID="Label3" runat="server" Text=" Ngày đặt hàng:" Style="font-weight: bold"></asp:Label>
                                    </td>
                                    <td style="color: Black; white-space: nowrap" align="left">
                                        <uc1:Calendar ID="Calendar1" runat="server" />
                                        ~<uc1:Calendar ID="Calendar2" runat="Server" />
                                    </td>
                                    <td align="left" style="color: black">
                                    </td>
                                </tr>
                                <tr>
                                    <td class="td_MyOrder">
                                    </td>
                                    <td align="left" style="width: 20%; padding-top: 2px">
                                    </td>
                                    <td class="td_MyOrder" style="width: 20%">
                                    </td>
                                    <td align="left" style="color: black">
                                    </td>
                                    <td align="left" style="color: black">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="4" style="color: black">
                                        <asp:Button ID="btnSearch" runat="server" CssClass="btn_Common" ForeColor="PeachPuff"
                                            Text="Tìm kiếm" OnClick="btnSearch_Click" />
                                        <asp:Button ID="btnClear" runat="server" CssClass="btn_Common" ForeColor="PeachPuff"
                                            Text="Làm lại" OnClick="btnClear_Click" /></td>
                                    <td align="left" style="color: black">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td colspan="6" style="padding-left: 5px; padding-right: 5px">
                                        <asp:GridView ID="grvMaster" runat="server" AutoGenerateColumns="False" Width="100%"
                                            CellPadding="5" BorderStyle="Dotted" BorderWidth="1px" BorderColor="blue" DataKeyNames="OrderID"
                                            OnRowDataBound="grvMaster_RowDataBound" OnRowDeleting="grvMaster_RowDeleting"
                                            AllowPaging="True" OnPageIndexChanging="grvMaster_PageIndexChanging" PageSize="20">
                                            <Columns>
                                                <asp:TemplateField HeaderText="X&#243;a">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="lblDelete" runat="server" CommandName="delete" Text="<img src=../../Images/Icon/cmdDelete.gif border=0 alt=Delete>"></asp:LinkButton>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" Width="1%" HorizontalAlign="Center" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" Width="1%" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="M&#227; h&#243;a đơn" ControlStyle-BorderStyle="NotSet">
                                                    <ItemTemplate>
                                                        <a href="#" class="dialog_link" orderid='<%# Eval("OrderID") %>' status='<%# Eval("Status") %>'>
                                                            <span class="ui-icon ui-icon-newwin"></span>
                                                            <asp:Label ID="lblOrderID" runat="server" Text='<%# Eval("OrderID") %>' CssClass="TextOrderID"
                                                                Font-Bold="true"></asp:Label></a>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" Width="25%" HorizontalAlign="Center" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Số lượng">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblSoLuong" runat="server" Text='<%# Eval("Quantity") %>'></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" HorizontalAlign="Center" Width="5%" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" Wrap="False" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Th&#224;nh tiền (VNĐ)">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblThanhTien" runat="server" Text='<%# Eval("Total") %>'></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" HorizontalAlign="Right" Width="25%" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" Wrap="False" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Ng&#224;y đặt h&#224;ng">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblOrderDate" runat="server" Text='<%# Eval("OrderDate") %>'></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" HorizontalAlign="Center" Width="15%" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" Wrap="False" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Trạng th&#225;i">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblStatus" runat="server" Text='<%# Eval("Status") %>' Font-Bold="true"></asp:Label>
                                                    </ItemTemplate>
                                                    <ItemStyle CssClass="gv_BorderBasketGrv" HorizontalAlign="Center" Width="25%" Wrap="False" />
                                                    <HeaderStyle CssClass="gv_BorderBasketGrv" Wrap="False" />
                                                    <FooterStyle CssClass="gv_BorderBasketGrv" />
                                                </asp:TemplateField>
                                            </Columns>
                                            <EmptyDataTemplate>
                                                <div align="center">
                                                    <asp:Label ID="Label1" runat="server" Text="Không tìm thấy hóa đơn nào trong hóa đơn của bạn"
                                                        CssClass="lbl_TextDefault" ForeColor="red" BackColor="LightYellow"></asp:Label>
                                                </div>
                                            </EmptyDataTemplate>
                                            <RowStyle CssClass="gv_RowStyleBasket" />
                                            <AlternatingRowStyle CssClass="gv_AlternatingRowStyleBasket" />
                                            <HeaderStyle CssClass="gv_HeaderBasket" />
                                            <FooterStyle CssClass="gv_FooterBasket" />
                                            <PagerStyle CssClass="gv_FooterBasket" />
                                        </asp:GridView>
                                        <br />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right" class="td_Content_Footer_590" style="padding-right: 25px">
            </td>
        </tr>
    </table>
    <!-- ui-dialog -->
    <div id="dialog" title="CHI TIẾT ĐƠN ĐẶT HÀNG">
        <p>
            <asp:Panel ID="divLoading" class="div-loading" runat="server" Style="width: 100%;
                height: 20px">
            </asp:Panel>
            <div id="ifOderDetail">
            </div>
        </p>
    </div>
</div>

<script language="javascript" type="text/javascript">
    
      function fnShowOrderDetail(obj)
    {
        var width=700;
        var height=500;
        var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));
        var feature="width="+width+",height="+height+",menu=0,scrollbars=1,status=1,location=0,resizable=1,left=" + left + ",top=20,screenX=" + left + ",screenY=" + top;
        window.open("OrderDetail.aspx?OrderID="+obj.getAttribute("OrderID")+"&State="+obj.getAttribute("Status"),"",feature)
    }
</script>

